package com.macro.mall.task;

import com.macro.mall.mapper.XhsOrderMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Slf4j
@Service
@RequiredArgsConstructor
public class OrderTask {



    @Resource
    private XhsOrderMapper orderMapper;

    // 每5分钟执行一次
    @Scheduled(cron = "0 */1 * * * ?")
    public void cancelTimeoutOrders() {
        int count = orderMapper.updateTimeoutOrders();
        if (count > 0) {
            log.info("已自动取消{}笔超时未支付订单", count);
        }
    }
}
